The twelfth thoracic ventral rami (subcostal nerve) pass with the subcostal vessels, below the twelfth rib.  Before reaching the costal angle they give rise to lateral and collateral branches.

The twelfth lateral cutaneous branch pierces the internal and external oblique muscles and divides into anterior and posterior branches.  The anterior branch runs forwards pierces the external oblique muscle, traverses the iliac crest approximately 5cm posterior to the anterior superior iliac spine to terminate in the overlying skin including the anterior gluteal skin.  A few branches run to the greater trochanter of the femur.  The posterior branch passes back to terminate in the skin overlying latissimus dorsi.  

The twelfth anterior cutaneous branch is the terminal part of the collateral nerve.  The collateral nerve continues with the subcostal vessels along the inferior border of the twelfth rib to pierce the rectus abdominis muscle and the anterior layer of the rectus sheath, where it becomes the twelfth anterior cutaneous branch of the thorax and terminates in the overlying skin.

Supply
The twelfth lateral cutaneous branch supplies the muscular slips of the external oblique muscle, skin of the lower abdomen antero-inferiorly as far as the linea semilunaris and, the anterior gluteal skin and the skin overlying latissimus dorsi.  The anterior cutaneous branch supplies the rectus abdominis muscle and skin over the lower anterior abdominal wall.